package j06future;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class J1 {
    public static void main(String[] args) throws Exception{
        ExecutorService es = Executors.newFixedThreadPool(1);
        Future<Integer> f = es.submit(()->{
            System.out.println("请稍等，正在获取数据...");
            Thread.sleep(2000);
            return 2000;
        });
        System.out.println("f = " + f);
        //get程序暂停，
        int money = f.get();
        System.out.println("money = " + money);
    }
}

class J2{
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 100000; i++) {
                System.out.println("守护-"+i);

            }
        });
        //变成守护线程
        t1.setDaemon(true);
        t1.start();

        for (int i = 0; i < 1000; i++) {
            System.out.println("main-"+i);
        }

    }
}
